/*
 * @Author: 
 * @Date: 2022-02-09 16:21:38
 * @LastEditors: lqj
 * @LastEditTime: 2022-02-14 14:22:33
 * @Description: redux -> reducer
 */
const initState = [] // 初始化

const PERSON_INCREASE_ACTION = 'add'

const personCreate = data => ({ type: PERSON_INCREASE_ACTION, data })

function personRedux(pre = initState, action) {
  const { type, data } = action
  switch (type) {
    case PERSON_INCREASE_ACTION:
      // 此方法会返回原数组并对原数组改写，
      // pre.unshift(data)
      return [...pre, data]
    default:
      return [...pre]
  }
}

export {
  personCreate,
  personRedux
}